﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Jamhee.Noctiluca.WebServer;

namespace Jamhee.Noctiluca.LightWiki.PropertyFiles
{
    public class WikiConfiguration : WebConfiguration
    {
        protected WikiResponser _wikiResponser;

        protected const string INI_SECTION_WEBSITE_HOME_PAGE = "homepage";
        protected const string INI_SECTION_WEBSITE_SITE_NAME = "sitename";
        protected const string INI_SECTION_WEBSITE_SITE_LOGO = "sitelogo";
        protected const string INI_SECTION_WEBSITE_SITE_COPYRIGHT = "copyright";

        public WikiConfiguration(string webConfig)
            : base(webConfig)
        {
        }

        public override IWebResponser GetWebResponser()
        {
            if (_wikiResponser == null)
            {
                _wikiResponser = new WikiResponser();
            }

            return _wikiResponser;
        }

        public string GetHomePage()
        {
            if (_iniFile != null && _iniFile.Exist())
            {
                return _iniFile.IniReadValue(INI_SECTION_WEBSITE, INI_SECTION_WEBSITE_HOME_PAGE);
            }

            return string.Empty;
        }

        public string GetSiteName()
        {
            if (_iniFile != null && _iniFile.Exist())
            {
                return _iniFile.IniReadValue(INI_SECTION_WEBSITE, INI_SECTION_WEBSITE_SITE_NAME);
            }

            return string.Empty;
        }

        public string GetSiteLogo()
        {
            if (_iniFile != null && _iniFile.Exist())
            {
                return _iniFile.IniReadValue(INI_SECTION_WEBSITE, INI_SECTION_WEBSITE_SITE_LOGO);
            }

            return string.Empty;
        }

        public string GetCopyright()
        {
            if (_iniFile != null && _iniFile.Exist())
            {
                return _iniFile.IniReadValue(INI_SECTION_WEBSITE, INI_SECTION_WEBSITE_SITE_COPYRIGHT);
            }

            return string.Empty;
        }
    }
}
